<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title></title>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/font-awesome.css}" rel="stylesheet"/>
    <link th:href="@{/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css}" rel="stylesheet"/>
    <link th:href="@{/css/animate.css}" rel="stylesheet"/>
    <link th:href="@{/css/style.css}" rel="stylesheet"/>
</head>
<body>
<form class="form-horizontal m-t " id="submitForm" method="POST" action="/namecard/modifyNameCard">
    <div class="col-md-12">
        <div class="form-group">
            <label class="col-sm-2 control-label">联系人：</label>
            <div class="col-sm-4">
                <input type="text" name="cardUserName" class="form-control input-sm"
                       th:value="${nameCard.cardUserName}"/> <span
                    class="help-block m-b-none"></span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">部门：</label>
            <div class="col-sm-4">
                <input type="text" name="cardUserDept" class="form-control input-sm"
                       th:value="${nameCard.cardUserDept}"/> <span
                    class="help-block m-b-none"></span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">邮箱：</label>
            <div class="col-sm-4">
                <input type="text" name="cardUserEmail" class="form-control input-sm"
                       th:value="${nameCard.cardUserEmail}"/> <span
                    class="help-block m-b-none"></span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">电话：</label>
            <div class="col-sm-4">
                <input type="text" name="cardUserPhone" class="form-control input-sm"
                       th:value="${nameCard.cardUserPhone}"/> <span
                    class="help-block m-b-none"></span>
            </div>
            <input type="hidden" name="nameCardId" th:value="${nameCard.nameCardId}"/>
        </div>
        <div style="display:block; right: 10px; text-align: right; padding-top:10px ;">
            <input class="btn btn-primary btn-sm" id="submitButton" type="button" value="确认"
                   style="margin-right: 30px;"/>
            <input class="btn btn-file btn-sm" type="button" id="cancelButton" value="删除"/>
        </div>
        <!-- /input-group -->
    </div>
</form>
<!-- 全局js -->
<script th:src="@{/js/jquery.min.js}"></script>
<!--<script th:src="@{/js/jquery.js}"></script>-->
<script th:src="@{/js/bootstrap.min.js}"></script>


<script th:src="@{/js/plugins/layer/layer.min.js}"></script>
<!-- 自定义js -->
<script th:src="@{/js/content.js}"></script>
<script th:src="@{/js/plugins/layer/laydate/laydate.js}"></script>
<script th:src="@{/js/jquery.form.js}"></script>

<script th:inline="javascript">
    $(function () {
        $("#cancelButton").on("click", function () {
            $.ajax({
                url: "/namecard/delNameCard",
                type: "post",
                data: {
                    nameCardId: [[${nameCard.nameCardId}]],
                    nameCardName:[[${nameCard.cardUserName}]],
                    nameCardDept:[[${nameCard.cardUserDept}]],
                    nameCardEmail:[[${nameCard.cardUserEmail}]],
                    nameCardPhone:[[${nameCard.cardUserPhone}]]
                },
                success:function (data) {
                    if(data.code == 200){
                        layer.msg(data.msg);
                        setTimeout(function () {
                            parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            parent.layer.close(index);
                        }, 1000);
                    }else {
                        layer.msg(data.msg);
                    }
                }
            });
        });
        $("#submitButton").on("click", function () {
            $("#submitForm").ajaxSubmit({
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg);
                        setTimeout(function () {
                            parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            parent.layer.close(index);
                        }, 1000);
                    } else {
                        layer.msg(data.msg);
                    }
                }
            });
        });
    });
</script>
</body>
</html>